/**
 * Created by Administrator on 2019/4/3.
 */
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/tronorder/index',
                    //edit_url: 'order/tronorder/edit',
                    //del_url: 'order/tronorder/del',
                    //multi_url: 'order/tronorder/multi',
                    table: 'tron_order'
                }
            });


            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                columns: [
                    [
                        //{checkbox: true},
                        {field: 'id', title: __('ID'),visible:true},
                        {field: 'uid', title: __('用户ID'),visible:false},
                        {field: 'user.username', title: __('用户名')},
                        {field: 'type', title: __('交易类型'), formatter: Table.api.formatter.status, searchList: { 0: __('投资'), 1: __('提现')}},
                        {field: 'amt', title: __('交易额度'),operate:false},
                        {field: 'max_profit', title: __('最大收益额'),operate:false},
                        {field: 'profit', title: __('当前收益额'),operate:false},
                        {field: 'from_addr', title: __('发起交易合约地址'),operate:false},
                        {field: 'txid', title: __('交易hex'),operate:false},
                        {field: 'status', title: __('订单状态'), formatter: Table.api.formatter.status, searchList: {'-2': __('处理失败'),'-1': __('等待处理'), 0: __('等待结果'), 1: __('交易通过'), 2: __('交易失败')}},
                        {field: 'isout', title: __('出局状态'), formatter: Table.api.formatter.status, searchList: {0: __('正常'), 1: __('出局')}},
                        {field: 'createtime', title: __('发起时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                        {field: 'updatetime', title: __('获取结果时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                        {field: 'outtime', title: __('出局时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                    ]
                ]
            });


            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});